using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class AdminPredictions : System.Web.UI.Page
{
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        _predictionForm.OnSaveComplete += new SaveComplete(OnPredictionSaveComplete);
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!User.IsInRole("Admin")) throw new Exception("Only admins can view this page!");
    }

    protected void GridViewActivePredictions_SelectedIndexChanged(object sender, EventArgs e)
    {
        int predictionId = Convert.ToInt32(GridViewActivePredictions.SelectedRow.Cells[0].Text);
        _predictionForm.LoadPrediction(predictionId, false);
    }

    protected void GridViewNotYetActivePredictions_SelectedIndexChanged(object sender, EventArgs e)
    {
        int predictionId = Convert.ToInt32(GridViewNotYetActivePredictions.SelectedRow.Cells[0].Text);
        _predictionForm.LoadPrediction(predictionId, true);
    }

    protected void OnPredictionSaveComplete()
    {
        GridViewActivePredictions.DataBind();
        GridViewNotYetActivePredictions.DataBind();
    }
}
